<template>
  <div class="order">
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/welcome' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <el-row :gutter="20">
        <el-col :span="9">
          <el-input placeholder="请输入内容" clearable v-model="queryInfo.query" @close="checklIST">
            <el-button slot="append" icon="el-icon-search" @click="checklIST"></el-button>
          </el-input>
        </el-col>
      </el-row>
      <el-table :data="orderList" style="width: 100%" border stripe>
        <el-table-column label="ID" type="index"></el-table-column>
        <el-table-column label="订单编号" prop="order_number" width="400px"></el-table-column>
        <el-table-column label="订单价格" prop="order_price" width="90px"></el-table-column>
        <el-table-column label="是否付款" prop="pay_status">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.pay_status==0" type="warning">未付款</el-tag>
            <el-tag v-else type="info">已付款</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="是否发货" prop="is_send">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.is_send=='否'" type="warning">未发货</el-tag>
            <el-tag v-else type="info">已发货</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="下单时间" prop="update_time" width="150px">
          <template slot-scope="scope">{{scope.row.update_time | dateFormat}}</template>
        </el-table-column>

        <el-table-column label="操作" width="200px">
          <template slot-scope="scope">
            <el-button size="mini" type="primary" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
            <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">定位</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryInfo.pagenum"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="queryInfo.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </el-card>
  </div>
</template>
<script>
export default {
  name: 'order',
  data() {
    return {
      orderList: [],
      queryInfo: {
        query: '',
        pagenum: 1,
        pagesize: 5
      },
      total: 0
    }
  },
  created() {
    this.getOrderList()
  },
  methods: {
    getOrderList() {
      this.$axios
        .get('orders', {
          params: {
            query: this.queryInfo.query,
            pagenum: this.queryInfo.pagenum,
            pagesize: this.queryInfo.pagesize
          }
        })
        .then(result => {
        //   console.log(result)
          this.total = result.data.data.total
          this.orderList = result.data.data.goods
        })
    },
    handleEdit(index, row) {},
    handleDelete(index, row) {},
    handleSizeChange(val) {
      this.queryInfo.pagesize = val
      this.getOrderList()
    },
    handleCurrentChange(val) {
      this.queryInfo.pagenum = val
      this.getOrderList()
    },
    checklIST() {
      this.getOrderList()
    }
  }
}
</script>
<style scoped>
</style>